<script setup lang="ts">
import { ref } from 'vue';
import { shuhui } from '@/common/api/pledgeReward';

const emit = defineEmits<{
  (e: 'onRefresh'): void;
}>();

const show = ref(false);
const loading = ref(false);
const shId = ref('');

const close = () => {
  shId.value = '';
  show.value = false;
};

const onSubmit = async () => {
  loading.value = true;
  try {
    await shuhui({ id: shId.value });
    emit('onRefresh');
    close();
  } catch {
    /** empty */
  } finally {
    loading.value = false;
  }
};

defineExpose({
  open(id: string) {
    shId.value = id;
    show.value = true;
  },
});
</script>
<template>
  <div class="confirmDialog">
    <van-dialog v-model:show="show" show-cancel-button>
      <div class="text-center pt-11">
        <p>正在转出，确定要继续吗？</p>
        <p class="text-sm text-[#7A7A7A] mt-2">确定即7天倒计时开始</p>
      </div>
      <template #footer>
        <div class="flex justify-end p-5">
          <van-button class="!mr-3" block round @click="close">取消</van-button>
          <van-button round type="primary" block color="#EC2D69" @click="onSubmit" :loading="loading">
            确认
          </van-button>
        </div>
      </template>
    </van-dialog>
  </div>
</template>
<style lang="less" scoped></style>
